package com.cf.system.client;

import com.cf.system.entity.Role;
import com.cf.system.feign.RoleFeign;
import com.cf.system.service.RoleService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ChenFeng
 * @date 2021/11/8 3:09 下午
 * @description
 */
@RestController
@AllArgsConstructor
public class RoleClient implements RoleFeign {

    private final RoleService roleService;

    @Override
    public List<String> getRoleNamesByRoleIds(String roleIds) {
        return roleService.listByIds(Arrays.asList(roleIds.split(",")))
                .stream()
                .map(Role::getRoleName)
                .collect(Collectors.toList());

    }
}
